﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Register.Command;
using Register.DALFactory;
using Register.IDAL;
using Register.Model;
namespace Register.BLL
{
    /// <summary> 
    /// FileName: SystemManageBLL.cs    
    /// CLRVersion: 4.0.30319.269    
    /// Author: DoubleZ    
    /// Corporation:     
    /// Description:     
    /// DateTime: 2012/7/13 19:43:43    
    /// </summary>
  public  class SystemManageBLL
    {
      private static string typeNameKey = "ISystemManageDALKey";
      #region 系统日志查询
      public static List<Model.LogerInfo> GetPagedLogerInfo(int size, int pageIndex, string where)
      {
          ISystemManageDAL iLogerInfo = DALFactory<ISystemManageDAL>.Create(typeNameKey);
          try
          {
              return iLogerInfo.GetPagedLogerInfo(size, pageIndex, where);
          }
          catch (Exception e)
          {
              LogRecordHelper.LogNote("ERROR", e.Message);
              throw e;
          }
      }
      public static int GetLoggerInfoCount(string where)
      {
          ISystemManageDAL iLogerInfo = DALFactory<ISystemManageDAL>.Create(typeNameKey);

          try
          {
              return iLogerInfo.GetLogerInfoCount(where);
          }
          catch (Exception e)
          {
              LogRecordHelper.LogNote("ERROR", e.Message);
              throw e;
          }
      }
      #endregion
        #region 获取个人信息

      public static List<AdminInfo> GetAdminInfo(string AdminId)
      {
          try
          {
              ISystemManageDAL iParamter = DALFactory<ISystemManageDAL>.Create(typeNameKey);

              return iParamter.GetAdminInfo(AdminId);
          }
          catch (Exception e)
          {
              LogRecordHelper.LogNote("ERROR", e.Message);
              throw e;
          }
      }
 
        #endregion
        #region 更新个人信息
   
      public static bool UpdateAdminInfo(Model.AdminInfo model)
      {
          ISystemManageDAL iIAdminInfo = DALFactory<ISystemManageDAL>.Create(typeNameKey);
          try
          {
              if (iIAdminInfo.UpdateAdminInfo(model) > 0)
              {
                  return true;
              }
              else
                  return false;
          }
          catch (Exception e)
          {
              LogRecordHelper.LogNote("ERROR", e.Message);
              throw e;
          }
      }

        #endregion
      #region 检查个人用户名是否已经存在
      public static bool Exists(string adminName)
      {
          ISystemManageDAL iadminName = DALFactory<ISystemManageDAL>.Create(typeNameKey);

          try
          {
              return iadminName.Exists(adminName);
          }
          catch (Exception e)
          {
              LogRecordHelper.LogNote("ERROR", e.Message);
              throw e;
          }
      }

      #endregion
      #region 检查旧密码是否输入正确
      public static bool ExistsPwd(string pwd,string adminID)
      {
          ISystemManageDAL iadmin = DALFactory<ISystemManageDAL>.Create(typeNameKey);

          try
          {
              return iadmin.ExistsPwd(pwd,adminID);
          }
          catch (Exception e)
          {
              LogRecordHelper.LogNote("ERROR", e.Message);
              throw e;
          }
      }

      #endregion
    }
}
